﻿namespace DotRas
{
    using System;
    using System.Runtime.Serialization;
    using System.Security.Permissions;

    [Serializable]
    public class RasDialException : RasException
    {
        private int _extendedErrorCode;

        public RasDialException()
        {
        }

        public RasDialException(string message) : base(message)
        {
        }

        public RasDialException(int errorCode, int extendedErrorCode) : base(errorCode)
        {
            this._extendedErrorCode = extendedErrorCode;
        }

        protected RasDialException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            this._extendedErrorCode = (int) info.GetValue("ExtendedErrorCode", typeof(int));
        }

        public RasDialException(string message, Exception innerException) : base(message, innerException)
        {
        }

        [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.SerializationFormatter)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (info != null)
            {
                info.AddValue("ExtendedErrorCode", this._extendedErrorCode, typeof(int));
            }
            base.GetObjectData(info, context);
        }

        public int ExtendedErrorCode
        {
            get
            {
                return this._extendedErrorCode;
            }
        }
    }
}

